//
//  ViewController.m
//  DownloadTest
//
//  Created by Bad on 2018/5/18.
//  Copyright © 2018年 boxian. All rights reserved.
//

#import "ViewController.h"
#import "DownLoadUtils.h"
#import "DownloadMutilFiles.h"

@interface ViewController ()

@property (nonatomic, strong) NSArray *urls;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSLog(@"%ld", self.urls.count);
    
    NSString *path = [[NSBundle mainBundle].resourcePath stringByAppendingPathComponent:@"lmcs"];
    NSLog(@"path=%@", path);
    [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
    
    
    [DownloadMutilFiles downloadForUrls:self.urls fileNames:nil toFilePaths:@[path] downloadFailRetry:YES progress:^(double downloadProgress) {
        NSLog(@"%f", downloadProgress);
    } completionHandler:^(BOOL allSuccess, NSArray *errorUrls, NSArray *errors) {
        NSLog(@"%d, %@, %ld", allSuccess, errorUrls, errors.count);
    }];
    
}
    

- (NSArray *)urls {
    if (!_urls) {
        
        _urls = @[
                          @"http://lobby.jndsfs.com/res/lmcq/skin2/game_code_0.0.9.1.zip",
                          @"http://lobby.jndsfs.com/res/lmcq/skin2/resource/63/63e36e42_1321.json",
                          @"http://lobby.jndsfs.com/res/lmcq/skin2/resource/57/570af3b0_16031.mp3",
                          @"http://lobby.jndsfs.com/res/lmcq/skin2/resource/26/26fb3f2d_12897.mp3",
                          @"http://lobby.jndsfs.com/res/lmcq/skin2/resource/82/82088fb4_18539.mp3",
                          @"http://lobby.jndsfs.com/res/lmcq/skin2/resource/d3/d36be0a2_10266.mp3",
                          
                          ];
    }
    return _urls;
}

@end
